﻿using System;
using System.Diagnostics;
using AsyncLoggers.EnterpriseLibrary;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace AsyncLoggers.EntLib.Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            var stopwatch = Stopwatch.StartNew();

            const int numberOfMessagesToLog = 1000;

            for (int i = 0; i < numberOfMessagesToLog; i++)
            {
                Logger.Write(new LogEntry {Message = "Hi guys!" + i});
            }

            stopwatch.Stop();

            Console.WriteLine("Synchronous version: " + stopwatch.Elapsed);

            EntepriseAsyncLoggers.SwapSynchronousLoggerForAsynchronous();

            stopwatch.Restart();

            for (int i = 0; i < numberOfMessagesToLog; i++)
            {
                Logger.Write(new LogEntry { Message = "Hi guys!" + i });
            }

            stopwatch.Stop();

            Console.WriteLine("Asynchronous version: " + stopwatch.Elapsed);

            Console.ReadLine();
        }
    }
}